<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增业务系统')" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-businessSystem-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">业务系统名称：</label>
                <div class="col-sm-8">
                    <input name="businessSystemName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">业务系统描述：</label>
                <div class="col-sm-8">
                    <input name="businessSystemDescription" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">分类节点：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="categoryId" name="categoryId" type="hidden" />
                        <input class="form-control" type="text" onclick="selectCategoryTree()" id="categoryName" readonly="true" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">表：</label>
                <div class="col-sm-8">
                    <select name="tableId" id="tableId" class="form-control selectpicker" multiple data-live-search="true" title="请选择">
                        <option th:each="table : ${tableList}" th:text="${table.tableName}" th:value="${table.id}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "businessSystem/businessSystem"
        $("#form-businessSystem-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $('#form-businessSystem-add').serializeArray();
                var tableIds = $('#tableId').selectpicker('val');
                data.push({"name": "tableIds", "value": tableIds});
                $.operate.save(prefix + "/add", data);
            }
        }

        var prefix2 = ctx + "category/category"
        /*分类体系-新增-选择父分类体系树*/
        function selectCategoryTree() {
            var options = {
                title: '分类体系选择',
                width: "380",
                url: prefix2 + "/selectCategoryTree2/0/1",
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#categoryId").val(body.find('#treeId').val());
            $("#categoryName").val(body.find('#treeName').val());
            layer.close(index);
        }

        $(function () {
            // $('#tableId').selectpicker({
            //     placeholder: "请选择表",
            //     allowClear: true,
            //     multiple:true
            // });
        });

    </script>
</body>
</html>